//
//  CTQGHeaderView.m
//  digitalCurrency
//
//  Created by 默认账户 on 2019/6/2.
//  Copyright © 2019 XinHuoKeJi. All rights reserved.
//

#import "CTQGHeaderView.h"

@interface CTQGHeaderView ()

@end

@implementation CTQGHeaderView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor blackColor];
        [self createView];
    }
    return self;
}
    
- (void)createView {
   
    UILabel *label = [[UILabel alloc] init];
    [self addSubview:label];
    label.textColor = [UIColor whiteColor];
    label.font = [UIFont systemFontOfSize:14];
    NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:LocalizationKey(@"Panic buying countdown") attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Regular" size: 14],NSForegroundColorAttributeName: [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0]}];
    label.attributedText = string;
    self.qgTitle = label;
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(20);
        make.height.mas_equalTo(18);
    }];
    
    NSArray *texts = @[@":",@":",@""];
    NSArray *times = @[@"00",@"00",@"00"];
    for (int i = 0; i < 3; i++) {
        UILabel *time = [[UILabel alloc] init];
        time.backgroundColor = [UIColor colorWithHEX:mainBlackColor];
        time.textAlignment   = NSTextAlignmentCenter;
        time.layer.cornerRadius = 4;
        time.text = times[i];
        time.font = [UIFont systemFontOfSize:14];
        time.textColor = [UIColor whiteColor];
        if (i == 0) {
            self.hourTime = time;
        }
        else if (i == 1) {
            self.miniteTime = time;
        }
        else {
            self.secondTime = time;
        }
        [self addSubview:time];
        [time mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_equalTo(self).mas_offset(-80 + i * 83);
            make.top.mas_equalTo(64);
            make.width.mas_equalTo(45);
            make.height.mas_equalTo(30);
        }];
        UILabel *text = [[UILabel alloc] init];
        text.text = texts[i];
        text.textColor = [UIColor whiteColor];
        text.font = [UIFont systemFontOfSize:18];
        [self addSubview:text];
        [text mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(time.mas_right).offset(15);
            make.top.mas_equalTo(68);
            make.width.mas_equalTo(15);
            make.height.mas_equalTo(18);
        }];
    }
    
    self.qgbtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.qgbtn setImage:[UIImage imageNamed:@"qianggou_btn"] forState:UIControlStateNormal];
    [self addSubview:self.qgbtn];
    [self.qgbtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(75);
        make.width.height.mas_equalTo(260);
    }];
}

@end
